<template>
    <el-table :data="students">
            <el-table-column prop="name" label="姓名"></el-table-column>
            <el-table-column prop="id" label="10"></el-table-column>
            <template v-if="userStore.isoggedIn && userStore.role === 'teacher'">
                <el-table-column prop="age" label="年龄"></el-table-column>
                <el-table-column prop="major" label="专业"></el-table-column>
                <el-table-column label="成绩">
                    <template #default="scope">
                        <div>网站前端开发：{{ scope.row.grades.frontend }}</div>
                        <div>专业英语:{{ scope.row.grades.english }}</div>
                        <div>Python程序设计:{{ scope.row.grades.python }}</div>
                    </template>
                </el-table-column>
                <el-table-column label="操作">
                    <template #default="scope">
                        <el-button type="primary" size="small" @click="editGrades(scope.row.id)">编辑成绩</el-button>
                    </template>
                </el-table-column>
            </template>
    </el-table>
</template>

<script setup>
import { useMemberStore } from '../stores/member'
import { useUserStore } from '../stores/user'
import { useRouter } from 'vue-router'
import { computed } from 'vue'

const memberStore=useMemberStore()
const userStore = useUserStore()
const router = useRouter()

const students = computed(() => memberStore.getAllStudents)


const editGrades = (id) => {
    router.push('/students/edit/${id}')
}
</script>